<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加文章</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/animate.min.css" rel="stylesheet">
    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="__JS__/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet">
    <link href="__JS__/layui/css/layui.css"rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-10">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>单件入库</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentForm" method="post" action="{:url('express/oneinstore')}">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">运单号：</label>
                            <div class="input-group col-sm-4">
                                <input type="text" class="form-control" name="billcode" required="" aria-required="true">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">提货码：</label>
                            <div class="input-group col-sm-4">
                                <input type="text" class="form-control" name="content" required="" aria-required="true">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">快递公司：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control" name="company_code">
                                    <option value="ZTO">中通</option>
                                    <option value="STO">申通</option>
                                    <option value="YUNDA">韵达</option>
                                    <option value="SF">顺丰</option>
                                    <option value="HTO">汇通</option>
                                    <option value="YTO">圆通</option>
                                    <option value="EMS">EMS</option>
                                    <option value="ChinaPost">中国邮政</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">收件人手机号：</label>
                            <div class="input-group col-sm-4">
                                <input type="text" class="form-control" name="phone" required="" aria-required="true">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-6">
                                <!--<input type="button" value="提交" class="btn btn-primary" id="postform"/>-->
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>批量入库</h5>
                        </div>
                        <div class="ibox-content">
                            <div class="layui-upload-drag" style="margin-bottom: 20px" id="instore">
                                <i class="layui-icon">&#xe67c;</i>
                                <p>选择Excel文件,点击选择或将文件拖拽到此处</p>
                            </div>
                            <div>
                                <button type="button" class="layui-btn" id='file-submit'>
                                    <i class="layui-icon">&#xe609;</i>上传
                                </button>
                            </div>
                        </div>
                    </div>
            </div>
        </div>
    </div>
</div>
<script src="__JS__/jquery.min.js?v=2.1.4"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<script src="__JS__/content.min.js?v=1.0.0"></script>
<script src="__JS__/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script>
<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
<script src="__JS__/layui/layui.js"></script>
<script src="__JS__/jquery.form.js"></script>
<script type="text/javascript">

    var index = '';
    function showStart(){
        index = layer.load(0, {shade: false});
        return true;
    }

    function showSuccess(res){

        layer.ready(function(){
            layer.closeAll('loading');
            layer.closeAll();
            if(0 == res.code){
                layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0});
            }else{
                layer.msg(res.msg, {anim: 6});
            }
        });
    }

    $(document).ready(function(){
        // 添加角色
        var options = {
            beforeSubmit:showStart,
            success:showSuccess,
        };

        $('#commentForm').submit(function(){
            $(this).ajaxSubmit(options);
            return false;
        });

        $('#keywords').tagsinput('add', 'some tag');
        $(".bootstrap-tagsinput").addClass('col-sm-12').find('input').addClass('form-control')
            .attr('placeholder', '输入后按enter');

        // 上传图片
        layui.use('upload', function(){
            var upload = layui.upload;
            var myLayer;
            //执行实例
            var uploadInst = upload.render({
                elem: '#instore' //绑定元素
                ,url: "{:url('express/instore')}" //上传接口
                ,auto: false
                ,bindAction: '#file-submit'
                ,exts: 'xlsx'
                ,before: function(obj){
                    myLayer = layer.msg('请等待3-5分钟', {
                        icon: 16
                        ,shade: 0.01,
                        time: 0
                    });
                }
                ,done: function(res){
                    //上传完毕回调
                    showSuccess(res);
                }
                ,error: function(){
                    layer.msg('上传错误', {anim: 6});
                }
            });
        });
    });

    // 表单验证
    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
</script>
</body>
</html>
